﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DepartmentDetail.ascx.cs" Inherits="Pantry.Web.Users.Controls.DepartmentDetail" %>
<%@ Register TagPrefix="uc" TagName="ListContact" Src="~/Users/Controls/ListContact.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ListTypeOfBusiness" Src="~/Users/Controls/ListTypeOfBusiness.ascx" %>
<%@ Register TagPrefix="uc2" TagName="ListPostcode" Src="~/Users/Controls/ListPostcode.ascx" %>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="ButtonLookupPostcode" EventName="Click" />
            <asp:PostBackTrigger ControlID="ButtonSave"/>
            <asp:PostBackTrigger ControlID="ButtonBack"/>
            <asp:PostBackTrigger ControlID="ButtonInActive"/>
        </Triggers>
        <ContentTemplate>
<%--            <div class="g_12_tienvn">--%>
                <div class="widget_header">
			        <h4 class="widget_header_title wwIcon i_16_icons">Department Details</h4>
			        <div class="top-nav">
			            <asp:Button ID="ButtonInActive" runat="server" Text="In-active" CssClass="buttontop" OnClick="ButtonInActiveClick" OnClientClick="return confirm('Do you want to in-active this department ?')" />
			            <asp:Button ID="ButtonSave" runat="server" Text="Save" CssClass="buttontop" OnClick="ButtonSaveClick" OnClientClick="return validate();" />
			            <asp:Button ID="ButtonBack" runat="server" Text="Back" CssClass="buttontop" OnClick="ButtonBackClick" />
			        </div>
		        </div>
		        <div class="widget_contents_tienvn" id="content_tienvn">
		            <div class="g_6_tienvn">
                        <ul class="title_ul">
                            <li>Department Name <span style="color:Red">*</span></li>
                            <li>Department Short Description <span style="color:Red">*</span></li>
                            <li>Lead Contact <span style="color:Red">*</span></li>
                            <li>Copy Address From</li>
                            <li>Address Line 1</li>
                            <li>Address Line 2</li>
                            <li>Address Line 3</li>
                            <li>Postcode</li>
                            <li>Town/Village/City</li>
                            <li>County</li>
                            <li>National/Country</li>
                        </ul>
                        <ul class="control_ul">
                            <li>
                                <asp:HiddenField ID="HiddenFieldName" runat="server" />
                            <asp:TextBox ID="TextBoxName" runat="server"/></li>
                            <li><asp:TextBox ID="TextBoxDescription" runat="server" TextMode="MultiLine"/></li>
                            <li><asp:TextBox ID="TextBoxLeadContact" runat="server" CssClass="small_text" Enabled="false"/>
                                <asp:HiddenField ID="HiddenFieldContactId" runat="server" />
                                <asp:Button ID="ButtonLookupContact" runat="server" Text="Lookup" CssClass="buttonlookup lookupcontact" />
                            </li>
                            <li><asp:RadioButton ID="RadioButtonOrganization" CssClass="radio-button" runat="server" Text="Organization" GroupName="radio" OnCheckedChanged="RadioButtonOrganizationCheckedChanged" AutoPostBack="true"/>
                                <asp:RadioButton ID="RadioButtoParent" runat="server" GroupName="radio" AutoPostBack="true" OnCheckedChanged="RadioButtonOrganizationCheckedChanged" Text="Parent"/>
                            </li>
                            <li><asp:TextBox ID="TextBoxAddress1" runat="server"/></li>
                            <li><asp:TextBox ID="TextBoxAddress2" runat="server"/></li>
                            <li><asp:TextBox ID="TextBoxAddress3" runat="server"/></li>
                            <li><asp:TextBox ID="TextBoxPostcode" runat="server" CssClass="small_text"/>
                                <asp:Button ID="ButtonLookupPostcode" runat="server" Text="Lookup" CssClass="buttonlookup lookupPostcode"/>
                            </li>
                            <li><asp:TextBox ID="TextBoxTown" runat="server"/></li>
                            <li><asp:TextBox ID="TextBoxCounty" runat="server"/></li>
                            <li><asp:DropDownList ID="DropDownListNational" runat="server">
                                <asp:ListItem Text="Vietnam"></asp:ListItem>
                            </asp:DropDownList></li>
                        </ul>
                    </div>
                    <div class="g_6_tienvn">
                        <ul class="title_ul">
                            <li>Type Of Business <span style="color:Red">*</span></li>
                            <li>SIC Code</li>
                            <li>Department Full Description</li>
                            <li>Phone Number</li>
                            <li>Fax</li>
                            <li>Email</li>
                            <li>Web Address</li>
                        </ul>
                        <ul class="control_ul">
                            <li><asp:TextBox ID="TextBoxTypeOfBusiness" runat="server" CssClass="small_text" Enabled="false"/>
                                <asp:HiddenField ID="HiddenFieldTypeOfBusinessId" runat="server" />
                                <asp:Button ID="ButtonLookupTypeOfBusiness" runat="server" Text="Lookup" CssClass="buttonlookup lookupBusiness" />
                            </li>
                            <li><asp:TextBox ID="TextBoxSicCode" runat="server" Enabled="false"/></li>
                            <li><asp:TextBox ID="TextBoxFullDescription" runat="server" TextMode="MultiLine"/></li>
                            <li><asp:TextBox ID="TextBoxPhoneNumber" runat="server" ToolTip="Format:+84978980800 or 0978980800"/></li>
                            <li><asp:TextBox ID="TextBoxFax" runat="server" ToolTip="Format:+84978980800 or 0978980800"/></li>
                            <li><asp:TextBox ID="TextBoxEmail" runat="server" ToolTip="Format:tienvn@fsoft.com.vn"/></li>
                            <li><asp:TextBox ID="TextBoxWebAddress" runat="server" ToolTip="http://web.com"/></li>
                        </ul>
                    </div>
                    <div class="clear"></div>
                    <span style="color:Red; padding-left:5px;">* is mandatory field</span>
		        </div>
<%--            </div>--%>
        </ContentTemplate>
    </asp:UpdatePanel>
    <div class="dialog DialogListContact" style="display:none;" title="Lookup Contact">
        <uc:ListContact runat="server" ID="ListContact" />
        <div class="clear"></div>
    </div>
    <div class="dialog DialogListOfBusiness" style="display:none;" title="Lookup Type Of Business">
        <uc1:ListTypeOfBusiness runat="server" ID="ListTypeOfBusiness" />
        <div class="clear"></div>
    </div>
    <div class="dialog DialogListOfPostCode" style="display:none;" title="Lookup Type Postcode">
        <uc2:ListPostcode runat="server" ID="ListPostcode" />
        <div class="clear"></div>
    </div>
    <script language="javascript" type="text/javascript">
    function validate()
    {
        if (document.getElementById("<%=TextBoxName.ClientID%>").value=="")
            {
                showmessage('Please input Department name !','ERROR','','false');
                document.getElementById("<%=TextBoxName.ClientID%>").focus();
                return false;
            }
        if (document.getElementById("<%=TextBoxDescription.ClientID%>").value=="")
            {
                showmessage('Please input short description !','ERROR','','false');
                document.getElementById("<%=TextBoxDescription.ClientID%>").focus();
                return false;
            }
        if (document.getElementById("<%=TextBoxLeadContact.ClientID%>").value=="")
            {
                showmessage('Please select lead contact !','ERROR','','false');
                document.getElementById("<%=TextBoxLeadContact.ClientID%>").focus();
                return false;
            }
        if (document.getElementById("<%=TextBoxTypeOfBusiness.ClientID%>").value=="")
            {
                showmessage('Please select type of business !','ERROR','','false');
                document.getElementById("<%=TextBoxTypeOfBusiness.ClientID%>").focus();
                return false;
            }
        if (document.getElementById("<%=TextBoxPhoneNumber.ClientID%>").value!="")
            {
                var phone = /^(\+|0)\d{9,11}$/;
                var phoneid=document.getElementById("<%=TextBoxPhoneNumber.ClientID %>").value;
                var matchArray = phoneid.match(phone);
                if (matchArray == null)
                {
                    showmessage('Phone number is invalid format !','ERROR','','false');
                    document.getElementById("<%=TextBoxPhoneNumber.ClientID %>").focus();
                    return false;
                }
            }
        if (document.getElementById("<%=TextBoxFax.ClientID%>").value!="")
            {
                var phone = /^(\+|0)\d{9,11}$/;
                var phoneid=document.getElementById("<%=TextBoxFax.ClientID %>").value;
                var matchArray = phoneid.match(phone);
                if (matchArray == null)
                {
                    showmessage('Fax number is invalid format !','ERROR','','false');
                    document.getElementById("<%=TextBoxFax.ClientID %>").focus();
                    return false;
                }
            }
        if(document.getElementById("<%=TextBoxEmail.ClientID %>").value!="")
            {
                var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
                var emailid=document.getElementById("<%=TextBoxEmail.ClientID %>").value;
                var matchArray = emailid.match(emailPat);
                if (matchArray == null)
                {
                    showmessage('Email is invalid format !','ERROR','','false');
                    document.getElementById("<%=TextBoxEmail.ClientID %>").focus();
                    return false;
                }
            }
        
        if(document.getElementById("<%=TextBoxWebAddress.ClientID %>").value!="")
            {
                var Url="^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$"
                var tempURL=document.getElementById("<%=TextBoxWebAddress.ClientID%>").value;
                var matchURL=tempURL.match(Url);
                if(matchURL==null)
                    {
                        showmessage('Web URL does not look valid !','ERROR','','false');
                        document.getElementById("<%=TextBoxWebAddress.ClientID %>").focus();
                        return false;
                    }
            }
        
        return true;
    }
</script>